package com.myapp.demo.config;

import com.gitee.fastmybatis.core.FastmybatisConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.apache.ibatis.solon.annotation.Db;
import org.noear.solon.annotation.Bean;
import org.noear.solon.annotation.Configuration;
import org.noear.solon.annotation.Inject;

import javax.sql.DataSource;

@Configuration
public class Config {

    @Bean(value = "db1", typed = true)
    public DataSource db1(@Inject("${dataSource.db1}") HikariDataSource ds) {
        return ds;
    }

    //todo: 如果有需求，可以通过 java 方式修改
    @Bean
    public void db1_cfg(@Db("db1")Configuration configuration,
                              @Db("db1") FastmybatisConfig globalConfig) {
        //configuration.setCacheEnabled(false);
        //globalConfig.setCountExpression("");
    }

}